<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Threaded</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="5">Threaded</font></b></p>

<br><b>Syntax</b><blockquote><pre><font face="Courier New, Courier, mono"size="2"><b><font color="#006666">Threaded</font></b>[.&lt;type&gt;] &lt;variable[.&lt;type&gt;]&gt; [= &lt;constant expression&gt;] [, ...]
</font></pre></blockquote>
<b>Description</b><br><blockquote>


<b><font color="#006666">Threaded</font></b> allows to create a <a href="../thread/index.html">thread based</a> persistent <a href="../reference/variables.html">variable</a>, 
<a href="../reference/dim.html">arrays</a>, <a href="../reference/newlist.html">lists</a> or <a href="../reference/newmap.html">maps</a>. This means 
every <a href="../thread/index.html">thread</a> will have its own version of the object. This is only useful when writing multithreaded programs. 
If a type is specified after <b><font color="#006666">Threaded</font></b>, the default type is changed for this declaration. <br>
<br>
Each variable can have a default value directly assigned to it, but it has to be a constant value. 
When declaring a threaded array, the dimension parameter has to be a constant value. <br>
<br>
A Threaded object can't be declared in a procedure, its scope is always global. 


 


</blockquote><p><b>Example:</b> With variables</p><blockquote>


<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">Threaded</font></b> Counter
  
  Counter = 128
  
  <b><font color="#006666">Procedure</font></b> <font color="#006666">Thread</font>(Parameter)
    
    <b><font color="#006666">Debug</font></b> Counter <font color="#006666">; Will display zero as this thread doesn't have used this variable for now</font>
    Counter = 256
    <b><font color="#006666">Debug</font></b> Counter <font color="#006666">; Will display 256</font>
    
  <b><font color="#006666">EndProcedure</font></b>
  
  Thread =<font color="#006666"> CreateThread</font>(@Thread(), 0)
<font color="#006666">  WaitThread</font>(Thread) <font color="#006666">; Wait for thread ending</font>
  
  <b><font color="#006666">Debug</font></b> Counter <font color="#006666">; Will display 128, even if Counter has been changed in the thread</font>
</font></pre>
</body></html>